<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>09-非父子组件之间的数据传递</title>
	<script src="vue.js"></script>
</head>
<body>
	<div id="root">
		<child count="Evan"></child>
		<child count="Zhang"></child>
	</div>
</body>
<script>
	Vue.prototype.bus=new Vue();
	Vue.component('child',{
		data:function(){
			return{
				selfContent:this.count
			}
		},
		props:['count'],
		template:"<div @click='clickMethod'>{{selfContent}}</div>",
		methods:{
			clickMethod:function(){
				this.bus.$emit('change',this.selfContent)
			}
		},
		mounted:function(){
			var that=this;
			this.bus.$on('change',function(msg){
				that.selfContent=msg
			})
		}
	})
	var vm=new Vue({
		el:'#root',
		methods:{
			
		}
	})
</script>
</html>